<template>
  <div>
     <el-table border style="margin: 10px 0px" :data="list">
      <el-table-column
        :label="$t('sys.operMan')"
        show-overflow-tooltip
        prop="modifyUserName"
      ></el-table-column>
      <el-table-column
        :label="$t('sys.operTime')"
        show-overflow-tooltip
        prop="modifyTime"
      ></el-table-column>
      <el-table-column
        :label="$t('sys.delete')"
        show-overflow-tooltip
        prop="accessDay"
      ></el-table-column>
      <el-table-column
        :label="$t('sys.speed')"
        show-overflow-tooltip
        prop="downloadSpeedSize"
      ></el-table-column>
      <el-table-column
        :label="$t('sys.empress')"
        show-overflow-tooltip
        prop="imgCompressSetting"
      ></el-table-column>
      <el-table-column
        :label="$t('sys.adviseNum')"
        show-overflow-tooltip
        prop="recommendeVesselsShowNum"
      ></el-table-column>
      <el-table-column
        :label="$t('sys.limit')"
        show-overflow-tooltip
        prop="uploadMax"
      ></el-table-column>
    </el-table>
    <el-pagination
      v-model:current-page="pageNo"
      v-model:page-size="pageSize"
      :page-sizes="[10, 20, 30, 40]"
      :background="true"
      layout="prev, pager, next, jumper,->,sizes,total"
      :total="total"
      @current-change="getPage"
      @size-change="handler"
    />
  </div>
</template>

<script setup lang="ts">
import { ref, onMounted } from 'vue'
import {setting} from '@/services'
import { settingHistory } from '@/api/system/setting'
import { ElMessage } from 'element-plus'

//组件挂载完毕
onMounted(() => {
  getPage()
})

//分页器当前页码
let pageNo = ref<number>(1)
//每一页展示几条数据
let pageSize = ref<number>(10)
let total = ref<number>(0)
let list = ref([])
const getPage = async (pager = 1) => {
  //当前分页器的页码
  pageNo.value = pager
  let { status, data, msg } = await settingHistory({
    pageNo: pageNo.value,
    pageSize: pageSize.value,
  })
  if (status == 200) {
    let { records, total: tatalNums } = data
    total.value = tatalNums
    list.value = records
  } else {
    ElMessage({ type: 'error', message: msg })
  }
}

//分页器下拉菜单发生变化触发
const handler = (pageSizes: number) => {
  getPage()
}

const refresh = () => {
  pageNo.value = 1
  getPage()
}


defineExpose({
  refresh,
})
</script>
